/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

import request from '@/router/axios'

export function fetchList(query) {
  return request({
    url: '/estate/rmproject/page',
    method: 'get',
    params: query
  })
}

export function addObj(obj) {
  return request({
    url: '/estate/rmproject',
    method: 'post',
    data: obj
  })
}

export function getObj(id) {
  return request({
    url: '/estate/rmproject/' + id,
    method: 'get'
  })
}
export function getObjs(id) {
  return request({
    url: '/rmproject/' + id,
    method: 'get'
  })
}

export function delObj(id) {
  return request({
    url: '/estate/rmproject/' + id,
    method: 'delete'
  })
}

export function putObj(obj) {
  return request({
    url: '/estate/rmproject',
    method: 'put',
    data: obj
  })
}

//获取关联合同数据
export function getContractList(query) {
  var query = {
    current: 1,
    size: 20
  };
  return request({
    url: '/contract/ctcontract/page',
    method: 'get',
    params: query
  })
}

//获取房产性质
export function getProjectpProperty() {
  return request({
    url: '/admin/dict/type/rm_project_property',
    method: 'get'
  })
}

//获取房产状态
export function getProjectStatus() {
  return request({
    url: '/admin/dict/type/rm_project_status',
    method: 'get'
  })
}

//获取房产类型
export function getProjectType() {
  return request({
    url: '/admin/dict/type/rm_project_buiding_type',
    method: 'get'
  })
}

//根据房产类型获取关联房产列表
export function getSysProjectType(buildingType) {
  if (buildingType == 1) {
    return request({
      url: '/admin/dict/type/exclusive_shop',
      method: 'get'
    })
  } else if (buildingType == 2) {
    return request({
      url: '/admin/dict/type/complex_building',
      method: 'get'
    })
  } else if (buildingType == 3) {
    return request({
      url: '/admin/dict/type/exhibition',
      method: 'get'
    })
  }
}

//获取操作日志
export function getOperationLog(id) {
  return request({
    url: '/config/sysoperationlog/' + id + '/1', //1.房产 2.车辆 3.合同
    method: 'get'
  })
}

//获取历史记录
export function getModifyLog(id) {
  return request({
    url: '/estate/rmprojectmodifylog/' + id,
    method: 'get'
  })
}


// 下载模板附件
export function loadFile() {
  return request({
    url: '/estate/DownLoadFile?FileType=2',
    method: 'get',
    responseType: 'arraybuffer',
    downloadFlag: true
  })
}

// 合同信息
export function getDetail(obj) {
  return request({
    url: '/estate/rmproject/getRmProjectContract',
    method: 'get',
    params: obj
  })
}
// 房产导入
export function ImportFile(obj) {
  return request({
    url: '/estate/rmproject/import',
    method: 'post',
    data: obj
  })
}
// 新增房产/rmproject/{id}
export function addHouse(obj) {
  return request({
    url: '/estate/rmproject/save',
    method: 'post',
    data: obj
  })
}
//详情/rmproject/{id}
export function Houselist(id) {
  return request({
    url: `/rmproject/${id}`,
    method: 'get',
    
  })
}
